using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class GameOverUI : MonoBehaviour
{
    public static GameOverUI Instance { get; private set; } // 静态实例

    private void Awake()
    {
        Instance = this; // 实例化静态实例

        // 获取重试按钮并添加点击事件监听器
        transform.Find("retryBtn").GetComponent<Button>().onClick.AddListener(() =>
        {
            GameSceneManager.Load(GameSceneManager.Scene.GameScene);
        });
        
        // 获取主菜单按钮并添加点击事件监听器
        transform.Find("mainMenuBtn").GetComponent<Button>().onClick.AddListener(() =>
        {
            // GameSceneManager.Load(GameSceneManager.Scene.MainMenuScene);
        });

        Hide(); // 隐藏UI界面
    }

    public void Show()
    {
        gameObject.SetActive(true); // 显示UI界面

        // 获取WaveSurvivedText并设置文本内容
        TextMeshProUGUI waveSurvivedText = transform.Find("wavesSurvivedText").GetComponent<TextMeshProUGUI>();
        waveSurvivedText.SetText("您坚持了 " + EnemyWaveManager.Instance.GetWaveNumber() + " 波!");
    }

    public void Hide()
    {
        gameObject.SetActive(false); // 隐藏UI界面
    }
}
